package com.lcy.demowebsocket.jms;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import com.lcy.demowebsocket.websocket.MyWebSocket;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArraySet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 订阅消息
 */
@Component
public class Consumer {

	@Autowired
	private MyWebSocket myWebSocket;
    /**
     * 监听 topic
     * @param text
     * @throws IOException
     */
    @SuppressWarnings("static-access")
	//从消息队列中拿到消息，转发给接受者（这是一个服务）
    @JmsListener(destination = "message")
    public void receiveQueue(String text) throws IOException {
    	//拿到消息后群发至客户端
    	myWebSocket.sendInfo(text);
    	System.out.println(text);
    }
}
